package com.xiaocz.hblsubstitutedriving.adapter;

import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.TextView;

import com.xiaocz.common.widgets.recycler.RecyclerViewAdapter;
import com.xiaocz.hblsubstitutedriving.R;
import com.xiaocz.hblsubstitutedriving.model.WithDrawDeposit;


/**
 * Author:  xiaocz.
 * Date:    2018/05.04.
 * Descr:  提现记录
 */
public class WithdrawDepositListAdapter extends RecyclerViewAdapter<WithDrawDeposit> {

    public WithdrawDepositListAdapter(AdapterListener<WithDrawDeposit> adapterListener) {
        super(adapterListener);
    }

    @Override
    protected int getItemViewType(int position, WithDrawDeposit data) {
        return R.layout.item_withdraw_deposit_list;
    }

    @Override
    protected ViewHolder<WithDrawDeposit> getViewHolder(View view, int viewType) {
        return new InfoTypeViewHolder(view);
    }

    private static class InfoTypeViewHolder extends ViewHolder<WithDrawDeposit> {

        private TextView tvTitle, tv_state, tv_money, tv_create_time;

        public InfoTypeViewHolder(View itemView) {
            super(itemView);
            tvTitle = itemView.findViewById(R.id.info_title);
            tv_state = itemView.findViewById(R.id.tv_state);
            tv_money = itemView.findViewById(R.id.tv_money);
            tv_create_time = itemView.findViewById(R.id.tv_create_time);
        }

        @Override
        protected void onBind(WithDrawDeposit data, int position) {
            tvTitle.setText(data.getOrderNo());
            String withdrawDeposit = "";
            int textColor = ContextCompat.getColor(mContext, R.color.colorAccent);
            switch (data.getStatus()) {
                case 1://1-提现中 2-提现成功 3-提现失败
                    withdrawDeposit = "已申请";
                    textColor = ContextCompat.getColor(mContext, R.color.textColorOrange);
                    break;
                case 2:
                    withdrawDeposit = "已到账";
                    textColor = ContextCompat.getColor(mContext, R.color.colorAccent);
                    break;
                case 3:
                    withdrawDeposit = "提现失败";
                    textColor = ContextCompat.getColor(mContext, R.color.textColorRed);
                    break;
            }
            tv_state.setTextColor(textColor);
            tv_state.setText(withdrawDeposit);
            tv_money.setText(String.valueOf(data.getMoney()));
            tv_create_time.setText(data.getCreatetime());
        }

        @Override
        public boolean isNeedClick() {
            return true;
        }
    }
}